package com.hyzx.qbasic.admin.domain.repository.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hyzx.qbasic.admin.model.po.SysConfigPO;
import com.hyzx.qbasic.admin.domain.dao.SysConfigMapper;
import com.hyzx.qbasic.admin.domain.repository.ISysConfigRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by 黄江华 on 2018/7/23
 */

@Repository
public class SysConfigRepositoryImpl implements ISysConfigRepository {

    @Autowired
    private SysConfigMapper configMapper;

    @Override
    public PageInfo<SysConfigPO> getPagedConfigList(int pageNum, int pageSize, String confKey) {
        PageInfo pageInfo = PageHelper.startPage(pageNum, pageSize)
                .doSelectPageInfo(() -> configMapper.getPagedConfigList(confKey));

        return pageInfo;
    }

    @Override
    public boolean addConfig(SysConfigPO config) {
        return configMapper.addConfig(config) > 0;
    }

    @Override
    public boolean deleteConfig(List<Integer> confIdList) {
        return configMapper.deleteConfig(confIdList) > 0;
    }

    @Override
    public SysConfigPO getConfigInfoById(int confId) {
        return configMapper.getConfigInfoById(confId);
    }

    @Override
    public List<SysConfigPO> getAllConfigList() {
        return configMapper.getAllConfigList();
    }

    @Override
    public SysConfigPO getConfigInfoByKey(String confKey) {
        return configMapper.getConfigInfoByKey(confKey);
    }

    @Override
    public boolean editConfig(SysConfigPO config) {
        return configMapper.editConfig(config) > 0;
    }
}
